package com.sun;

import reactor.core.publisher.Flux;

import java.io.*;
import java.net.Socket;

/**
 * @author 烛龙神
 * @Description TODO
 * @date 2021-04-09 07:37
 */
public class SocketClient {

    public static void main(String[] args) {
        Socket socket;
        OutputStream outputStream;
        InputStream inputStream;
        try {
             socket = new Socket("localhost", Integer.parseInt("8888"));
             inputStream = socket.getInputStream();
             outputStream = socket.getOutputStream();

            BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream));
            bufferedWriter.write("测试客户端和服务器通信，服务器接收到消息返回到客户端\n");
            bufferedWriter.flush();

            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
            String str = bufferedReader.readLine();
            System.out.println("服务器:" + str);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
